package com.heima.wemedia.controller.v1;

import com.heima.common.constants.WemediaConstants;
import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.wemedia.dtos.WmMaterialDto;
import com.heima.wemedia.service.WmMaterialService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

/**
 * @Author:篍
 * @Date: 2025/09/18 16:48
 * @Description:
 */
@RestController
@RequestMapping("/api/v1/material")
public class WmMaterialController {

    @Autowired
    private WmMaterialService wmMaterialService;

    /**
     * 上传素材
     * @param multipartFile 素材
     * @return 素材对象
     */
    @PostMapping("/upload_picture")
    public ResponseResult uploadPicture(@RequestBody MultipartFile  multipartFile){
        return wmMaterialService.uploadPicture(multipartFile);
    }

    /**
     * 素材列表
     * @param dto
     * @return 素材列表
     */
    @PostMapping("/list")
    public ResponseResult list(@RequestBody WmMaterialDto dto){
        return wmMaterialService.listMaterial(dto);
    }

    /**
     * 收藏素材
     * @param id 素材id
     * @return
     */
    @GetMapping("/collect/{id}")
    public ResponseResult collect(@PathVariable Integer id){
        return wmMaterialService.collectMaterial(id);
    }

    /**
     * 取消收藏素材
     * @param id 素材id
     * @return
     */
    @GetMapping("/cancel_collect/{id}")
    public ResponseResult cancelCollect(@PathVariable Integer id){
        return wmMaterialService.cancelCollect(id);
    }

    /**
     * 删除素材
     * @param id 素材id
     * @return
     */
    @GetMapping("del_picture/{id}")
    public ResponseResult delPicture(@PathVariable Integer id){
        return wmMaterialService.delPicture(id);
    }

}
